﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DatabaseCompare.Model;
using DatabaseCompare.Service.Compare;

namespace DatabaseCompare.ServiceImpl.Compare
{

    /// <summary>
    /// 存储过程比较.
    /// </summary>
    public class ProcedureCompare :
        CompareAbleCompare<ProcedureInfo>,
        ICompareAbleCompare<ProcedureInfo, ProcedureCompareResult>
    {


        public ProcedureCompareResult Compare(ProcedureInfo left, ProcedureInfo right)
        {
            // 比较结果.
            ProcedureCompareResult result = new ProcedureCompareResult();

            // 设置比较参数.
            result.Left = left;
            result.Right = right;

            // 首先简单作非空的判断.
            result.CompareResult = base.CommonCompare(left, right);


            if (result.CompareResult == CommonCompareResult.FullSame)
            {
                // 左右都不为空
                // 需要详细比较.

                // 创建的 SQL 语句.
                if (left.CreateSQL != right.CreateSQL)
                {
                    result.CompareResult = CommonCompareResult.Difference;
                    result.CreateSQLDifference = true;
                }
            }


            // 返回.
            return result;
        }
    }
}
